﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Login : System.Web.UI.Page {
	ServerProvider.ServiceSoapClient cl = new ServerProvider.ServiceSoapClient();
	
	protected void Page_Load(object sender, EventArgs e) {
		if (Session["loggedIn"] == null)
			Session["loggedIn"] = false;
		else if ((bool)Session["loggedIn"] == true)
			Response.Redirect("~/Default.aspx");
	}
	protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) {
		string name = (sender as Login).UserName;
		Session["userName"] = name;
		e.Authenticated = cl.LogIn(name);
	}
	protected void Login1_LoggedIn(object sender, EventArgs e) {
		Session["dateTime"] = cl.GetDateTimeNow();
		Session["loggedIn"] = true;
		Response.Redirect("~/Default.aspx");
	}
}
